/*
 * AppImpl.cpp
 *
 *  Created on: 4 sty 2014
 *      Author: Paweł Macioł
 */
#include "fv_config.h"
#include "defs.h"
#include "AppImpl.hpp"
#include "WindowFV.h"
#include "ModelControler.h"
#include "pch_intf.h"
#include <string>
#include <unistd.h>








//#ifdef _USE_FV_LIB
//static mfvKernel * Kernel_Ptr = NULL;
//
//int init(int argc, char **argv, FILE *out) {
//	if (Kernel_Ptr == NULL) {
//		try {
//			Kernel_Ptr = new mfvKernel();
//		}
//		catch (const std::bad_alloc & e) {
//			std::string msg("Error during graphic kernel init: ");
//			msg.append( e.what());
//			msg.append( "\n");
//			throw msg;
//		}
//	}
//
//	if (Kernel_Ptr->_handle == 0) {
//		mfvKernel::runParams params_ = {argc, argv, out};
//#ifdef PARALLEL
//		if (pcr_my_proc_id() == pcr_print_master())
//			Kernel_Ptr->_handle = (fv_thread)fv_start_thread(&Kernel_Ptr->_id,Kernel_Ptr->run_master,params_);
//		else
//			Kernel_Ptr->_handle = (fv_thread)fv_start_thread(&Kernel_Ptr->_id,Kernel_Ptr->run_slave,params_);
//#else
//		Kernel_Ptr->_handle = (fv_thread)fv_start_thread(&Kernel_Ptr->_id,Kernel_Ptr->run,params_);
//#endif
//	}
//	return static_cast<int>(Kernel_Ptr->_handle);
//}
//
//
//void shut_down(void) {
//
//	if (Kernel_Ptr != NULL)
//	{
//		// Signal and of the work
//		ENTERCRITICALSECTION(Kernel_Ptr->_crtsec);
//		Kernel_Ptr->_run = false;
//		LEAVECRITICALSECTION(Kernel_Ptr->_crtsec);
//
//		// Wait until thead is finished
//		fv_end_thread(Kernel_Ptr->_handle);
//
//		// Sllep for one second and destroy kernel
//		sleep(1);
//		delete Kernel_Ptr;
//		Kernel_Ptr = NULL;
//	}
//
//}
//
//#else
//static mfvKernel Kernel_Impl;
//#endif
//
//#ifdef PARALLEL
//fv_thread_return mfvKernel::run_master(void *params) {
//
//	mfvKernel::runParams * pParams = reinterpret_cast<mfvKernel::runParams *>(params);
//	return static_cast<fv_thread_return>( AppEngine::Init(pParams->nargc,pParams->pargv) );
//}
//
//fv_thread_return mfvKernel::run_slave(void *params) {
//
//	mfvKernel::runParams * pParams = reinterpret_cast<mfvKernel::runParams *>(params);
//	ModelCtrInst().Do(ModelCtrl::INIT);
//	return static_cast<fv_thread_return>( AppEngine::Init(pParams->nargc,pParams->pargv) );
//}
//#else
//fv_thread_return mfvKernel::run(void *params) {
//	mfvKernel::runParams * pParams = reinterpret_cast<mfvKernel::runParams *>(params);
//	return static_cast<fv_thread_return>( AppEngine::Init(pParams->nargc,pParams->pargv) );
//}
//#endif
//
//}


